package com.school.appleforgetbackend.controller;

import com.school.appleforgetbackend.jpa.entity.AccountInfoEntity;
import com.school.appleforgetbackend.model.AccountInfo;
import com.school.appleforgetbackend.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Apple
 */
@Controller
@RequestMapping("/apple")
@CrossOrigin(origins = {"http://193.233.84.94", "http://127.0.0.1", "http://apple-account-forget.top",
        "http://apple-forget-account.top"}, allowCredentials = "true")
public class ResetPasswordController {
    @Autowired
    AccountService accountService;

    @RequestMapping(value = "/saveInfo")
    @ResponseBody
    public ResponseEntity<AccountInfoEntity> saveInfo(@RequestBody AccountInfo accountInfo) {
        AccountInfoEntity accountInfoEntity = accountService.createAccountInfo(
                accountInfo.getPhoneNumber(), accountInfo.getPassword());
        return ResponseEntity.ok(accountInfoEntity);
    }
}
